﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entidades1;
using Logica;

namespace WebSisVet1
{
    public partial class RegVeterinario : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //1.txtCedula.Text = Request.QueryString["Cedula"].ToString();
            if (Session["Cedula"] != null)
            {

                //if (Session["bd"] == "postgre") { Radio.Checked = true; } else if (Session["bd"] == "oracle") { ridioO.Checked = true; } else { Radio1.Checked = true; };

                hdOper.Value = "act";
                txtCedula.Text = Session["cedula"].ToString();
                txtNombre.Text = Session["nombre"].ToString();
                txtApellido.Text = Session["apellido"].ToString();
                txtTelefono.Text = Session["telefono"].ToString();
                txtDireccion.Text = Session["direccion"].ToString();
                txtEmail.Text = Session["email"].ToString();

                //buscar el ctacto especifico
                //mostrarlo
                Session["bd"] = null;
                Session["Cedula"] = null;
            }
            else
            {

                hdOper.Value = "new";

            }
        }

        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            VeterinarioBLL vbll = new VeterinarioBLL();
            Veterinario v = new Veterinario();
            v.cedula = txtCedula.Text;
            v.nombre = txtNombre.Text;
            v.apellido = txtApellido.Text;
            v.telefono = txtTelefono.Text;
            v.direccion = txtDireccion.Text;
            v.email = txtEmail.Text;
            //if (Radio1.Checked) { c.bd = "mysql"; };
            //if (Radio.Checked) { c.bd = "postgre"; };
            //if (ridioO.Checked) { c.bd = "oracle"; };
            lbMsg.Text = vbll.Agregar(v);


        }
        protected void BtnActualizar_Click(object sender, EventArgs e)
        {
            VeterinarioBLL vbll = new VeterinarioBLL();
            Veterinario v = new Veterinario();
            v.cedula = txtCedula.Text;
            v.nombre = txtNombre.Text;
            v.apellido = txtApellido.Text;
            v.telefono = txtTelefono.Text;
            v.direccion = txtDireccion.Text;
            v.email = txtEmail.Text;
            //if (Radio1.Checked) { c.bd = "mysql"; };
            //if (Radio.Checked) { c.bd = "postgre"; };
            //if (ridioO.Checked) { c.bd = "oracle"; };
            lbMsg.Text = vbll.actualizar(v);


        }


        protected void BtnVolver_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/GestionVeterinario.aspx");
        }

        public char s { get; set; }
    }
}